Repository navigation
Add cloud writing for records and annotations - #694
Merged
Merged
Conversation
tompollard
commented
Nov 24, 2026
tompollard
left a comment
Member
Author
There was a problem hiding this comment.
Looks good, with nothing blocking. One test would be worth adding before merging, and a few small tidy-ups.
What I checked:
- Upload order: for a multi-segment record written to
memory://, I recorded each path opened for writing. The order wasv102s.dat, thenv102s_1.hea, thenv102s.hea, so the main header is last, and only the record's files were in the folder. - Nothing is published after an error: a check that fails (an invalid
fmt) uploads nothing, since the error is raised before the upload loop. - The overwrite warning works in the cloud: it checks the cloud folder, and reads the record's existing header from it. A
write_dirwith a trailing slash works. - Tests:
pytest -m "not network"(696 passed) and ruff pass.
Worth adding:
- A test for the upload order. Uploading the main header last is the property that keeps readers from finding a half-uploaded record, but no test covers it. A test could patch
wfdb.io._cloud._fsspec_opento record the paths opened for writing, write a multi-segment record, and check that the main header comes last.
Minor:
physionet://is rejected late inRecord.wrsamp._warn_about_replacing_other_filesruns beforestaged_cloud_writerejectsphysionet://, so it first asks PhysioNet whether the signal files exist:rec.wrsamp(write_dir="physionet://mitdb/1.0.0")takes about 1.1 s before raising. Offline it still raises the rightValueError. Rejectingphysionet://at the top ofwrsampwould avoid the requests, and the test could coverRecord.wrsampas well aswrann.- One misleading error. An open local
WFDBArchivewith a cloudwrite_dirraises "Writing .wfdb archives to cloud storage is unsupported", although the archive is local. Rejecting the combination is fine, but the message could say thatwrite_dirisn't used when writing to an open archive. - Duplicated checks. The two archive checks are repeated in
Record.wrsampandMultiRecord.wrsamp. A small helper in_cloud.py(for examplecheck_cloud_write(write_dir, wfdb_archive)) would keep them consistent, and could include thephysionet://check from 2.
Member
Author
|
Thanks for the thorough review. I addressed all four points in 33931a9:
Validation: 697 offline tests passed (4 skipped), Ruff passed, and the strict Sphinx build passed. |
tompollard
commented
Nov 24, 2026
tompollard
left a comment
Member
Author
There was a problem hiding this comment.
Re-reviewed 33931a9. All four points are addressed, and this is ready to merge.
- Upload order:
test_multi_record_wrsamp_to_cloudrecords every path opened for writing, and checks that the main header comes last. I confirmed that it fails ifstaged_cloud_writeuploads the main header first. physionet://:check_cloud_writerejects it before the overwrite lookup.Record.wrsamp(write_dir="physionet://mitdb/1.0.0")now fails in 0.000 s, instead of after about 1.1 s of PhysioNet requests, and the test checks that no lookup happens.- An open archive with a cloud
write_dirnow raises a clear "cloud write_dir is unused with an open WFDBArchive" error, and a test covers it. - Duplicated checks: both
wrsampmethods andAnnotation.wrannuse the sharedcheck_cloud_write. They are the only callers ofstaged_cloud_write, so no write path skips the check now thatstaged_cloud_writeno longer does it itself.
pytest -m "not network" (697 passed), ruff and the docs build with warnings as errors all pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
write_dirforwrsampandwrann, including single and multi-segment records.fsspec, publishing the main header last.Closes #517.
Validation
pytest -m 'not network' -q: 696 passed, 4 skipped, 20 deselected-W --keep-going: passedThe new write tests use
memory://and cover records, multi-segment records, annotations, failed validation, and overwrite warnings.